#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e3+100;
typedef int LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
LL a[maxn][maxn][2];
LL dp[maxn][maxn][2];
bool flag=0;
LL posx,posy,t;
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL n;cin>>n;
   for(LL i=1;i<=n;i++){
       for(LL j=1;j<=n;j++){
           LL x;cin>>x;
           if(x==0) {flag=1;posx=i;posy=j;}
           LL temp=x;
           while(temp>0){
                if(temp%2==0){
                    temp/=2;a[i][j][0]++;
                }
                else break;
           }
           temp=x;
           while(temp>0){
                if(temp%5==0){
                    temp/=5;a[i][j][1]++;
                }
                else break;
           }
       }
   }
   memset(dp,0x3f,sizeof(dp));
   dp[1][1][0]=a[1][1][0];dp[1][1][1]=a[1][1][1];
   for(LL i=2;i<=n;i++){
       dp[i][1][0]=dp[i-1][1][0]+a[i][1][0];
       dp[i][1][1]=dp[i-1][1][1]+a[i][1][1];
   }
   for(LL i=2;i<=n;i++){
       dp[1][i][0]=dp[1][i-1][0]+a[1][i][0];
       dp[1][i][1]=dp[1][i-1][1]+a[1][i][1];
   }
   for(LL i=2;i<=n;i++){
       for(LL j=2;j<=n;j++){
           dp[i][j][0]=min(dp[i-1][j][0],dp[i][j-1][0])+a[i][j][0];
           dp[i][j][1]=min(dp[i-1][j][1],dp[i][j-1][1])+a[i][j][1];
       }
   }
   LL ans=min(dp[n][n][0],dp[n][n][1]);
   if(ans>1&&flag){
      cout<<1<<"\n";
      for(LL i=1;i<posx;i++) cout<<"D";
      for(LL i=1;i<posy;i++) cout<<"R";
      for(LL i=posy;i<n;i++) cout<<"R";
      for(LL i=posx;i<n;i++) cout<<"D";
      cout<<"\n";
   }
   else{
      vector<char>v;
      LL i=n;LL j=n;
      LL res=0;
      if(dp[n][n][0]>dp[n][n][1]) res=1;
      while(1){
        if(dp[i-1][j][res]<dp[i][j-1][res]){
            i--;
            v.push_back('D');
        }
        else{
            j--;
            v.push_back('R');
        }
        if(i==1){
            for(LL k=1;k<j;k++) v.push_back('R');
            break;
        }
        if(j==1){
            for(LL k=1;k<i;k++) v.push_back('D');
            break;
        }
      }
      cout<<ans<<"\n";
      reverse(v.begin(),v.end());
      for(auto i:v){
          cout<<i;
      }
      cout<<"\n";
   }
   return 0;
}
